package com.hgx.alibaba.provider.payment.controller;

import com.hgx.alibaba.provider.payment.entity.Payment;
import com.hgx.springcloud.common.entities.response.CommonResultResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentDBController {

    @Value("${server.port}")
    private String serverPort;


    public static HashMap<Integer, Payment>  map = new HashMap<>() ;

    static {
        map.put(1,new Payment(1,"qweqweqwewqe12312312")) ;
        map.put(2,new Payment(2,"2132qweqweqew5675765")) ;
        map.put(3,new Payment(3,"xzcvxvcvx3453453454")) ;
    }


    @GetMapping("payment/{id}")
    public CommonResultResponse<Payment> getPayment(@PathVariable("id") Integer id) {
        Payment payment = map.get(id) ;
        return new CommonResultResponse<Payment>("200","OK,serverPort:"+serverPort,payment);
    }

}
